package com.mt.restaurant.entity.material;

import javax.persistence.*;
import java.io.Serializable;
import com.mt.common.core.annotation.DColumn;
import com.mt.common.core.annotation.DEntity;
import com.mt.common.core.web.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;



import com.mt.restaurant.entity.material.Material;
import com.mt.restaurant.entity.material.Supplier;

@DEntity(label="供应原材料",comment="",moduleLabel="原材料管理")
@Entity(name="restaurant_supply_material")
@Table(name = "restaurant_supply_material" , indexes = { @Index(name = "index_supplier_id", columnList = "supplier_id"),@Index(name = "index_material_id", columnList = "material_id")  })
@ApiModel(description = "供应原材料:")
public class SupplyMaterial extends BaseEntity implements Serializable{
	private static final long serialVersionUID = 1L;

	@DColumn(index=3,label="供应商",foreignEntity="Supplier",comment="供应商",component="对象选择",where=false)
	@ApiModelProperty(value = "供应商:供应商")
	@Column(name="supplier_id",length=255,nullable=true,unique=false)
	private Long supplierId;

	@Transient
	private Supplier supplier;

	@Transient
	@ApiModelProperty(value = "供应商名称:供应商")
	@DColumn(index=3,label="供应商",foreignEntity="Supplier",comment="供应商")
	private String supplierName;

	@DColumn(index=4,label="材料",foreignEntity="Material",comment="",component="对象选择",where=false)
	@ApiModelProperty(value = "材料:")
	@Column(name="material_id",length=255,nullable=true,unique=false)
	private Long materialId;

	@Transient
	private Material material;

	@Transient
	@ApiModelProperty(value = "材料名称:")
	@DColumn(index=4,label="材料",foreignEntity="Material",comment="")
	private String materialName;

	@DColumn(index=5,label="价格",comment="材料价格",component="数字，小数",where=false)
	@ApiModelProperty(value = "价格:材料价格")
	@Column(name="price",length=255,nullable=false,unique=false)
	private Double price;

	@DColumn(index=6,label="不合格次数",comment="不合格次数",component="数字，整数",where=false)
	@ApiModelProperty(value = "不合格次数:不合格次数")
	@Column(name="failures_num",length=255,nullable=true,unique=false)
	private Integer failuresNum;

	@DColumn(index=6,label="购买次数",comment="购买次数",component="数字，整数",where=false)
	@ApiModelProperty(value = "购买次数:购买次数")
	@Column(name="purchases",length=255,nullable=true,unique=false)
	private Integer purchases;

	@DColumn(index=7,label="昨日价格",comment="",component="数字，小数",where=false)
	@ApiModelProperty(value = "昨日价格:")
	@Column(name="tomorrow_price",length=255,nullable=true,unique=false)
	private Double tomorrowPrice;

	@DColumn(index=8,label="今日价格",comment="",component="数字，小数",where=false)
	@ApiModelProperty(value = "今日价格:")
	@Column(name="today_price",length=255,nullable=true,unique=false)
	private Double todayPrice;

	@DColumn(index=9,label="浮动比率",comment="",component="数字，小数",where=false)
	@ApiModelProperty(value = "浮动比率:")
	@Column(name="float_ratio",length=255,nullable=true,unique=false)
	private Double floatRatio;

	@DColumn(index=10,label="供应商库存",comment="",component="数字，小数",where=false)
	@ApiModelProperty(value = "供应商库存:")
	@Column(name="stock",length=255,nullable=false,unique=false)
	private Double stock;

	@Transient
	private Double quantity;

	@Transient
	private Double totalPrice;

	public Long getSupplierId() {
		return this.supplierId;
	}

	public void setSupplierId(Long supplierId) {
		this.supplierId = supplierId;
	}

	public Long getMaterialId() {
		return this.materialId;
	}

	public void setMaterialId(Long materialId) {
		this.materialId = materialId;
	}

	public Double getPrice() {
		return this.price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Integer getFailuresNum() {
		return this.failuresNum;
	}

	public void setFailuresNum(Integer failuresNum) {
		this.failuresNum = failuresNum;
	}

	public Integer getPurchases() {
		return purchases;
	}

	public void setPurchases(Integer purchases) {
		this.purchases = purchases;
	}

	public Double getTomorrowPrice() {
		return this.tomorrowPrice;
	}

	public void setTomorrowPrice(Double tomorrowPrice) {
		this.tomorrowPrice = tomorrowPrice;
	}

	public Double getTodayPrice() {
		return this.todayPrice;
	}

	public void setTodayPrice(Double todayPrice) {
		this.todayPrice = todayPrice;
	}

	public Double getFloatRatio() {
		return this.floatRatio;
	}

	public void setFloatRatio(Double floatRatio) {
		this.floatRatio = floatRatio;
	}

	public Supplier getSupplier() {
		return this.supplier;
	}

	public void setSupplier(Supplier supplier) {
		if(supplier == null){
		}
		else
		{
		this.supplierId = supplier.getEid();
		this.supplier = supplier;		
		}
}

	public String getSupplierName() {
		return this.supplierName;
	}

	public void setSupplierName(String supplierName) {
		this.supplierName = supplierName;
	}

	public Material getMaterial() {
		return this.material;
	}

	public void setMaterial(Material material) {
		if(material == null){
		}
		else
		{
		this.materialId = material.getEid();
		this.material = material;		
		}
}

	public String getMaterialName() {
		return this.materialName;
	}

	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}

	public Double getStock() {
		return stock;
	}

	public void setStock(Double stock) {
		this.stock = stock;
	}

	public Double getQuantity() {
		return quantity;
	}

	public void setQuantity(Double quantity) {
		this.quantity = quantity;
	}

	public Double getTotalPrice(){
		if(quantity!=null&&todayPrice!=null){
			return quantity*todayPrice;
		}
		return totalPrice;
	}

	public void setTotalPrice(){
		this.totalPrice = this.quantity*this.todayPrice;
	}
}
